/* Copyright (c) 2004-2024 Peigen.info. All rights reserved. */

package info.peigen.hotpot.business.router.test.base;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.RandomUtil;
import com.google.common.collect.Lists;
import info.peigen.hotpot.business.router.core.service.notify.GatewayNotifyService;
import info.peigen.hotpot.business.router.core.service.receipt.QueryReceiptChannelService;
import info.peigen.hotpot.business.router.core.service.receipt.ReceiptService;
import info.peigen.hotpot.business.router.core.service.virtualaccount.VirtualAccountManageService;
import info.peigen.hotpot.business.router.core.service.virtualaccount.VirtualAccountService;
import info.peigen.hotpot.business.router.core.service.withdraw.MultipleWithdrawService;
import info.peigen.hotpot.business.router.core.service.withdraw.WithdrawService;
import info.peigen.hotpot.common.core.domain.order.*;
import info.peigen.hotpot.common.core.enums.Currency;
import info.peigen.hotpot.common.core.lang.money.Money;
import info.peigen.hotpot.common.core.util.IdUtil;
import lombok.AccessLevel;
import lombok.experimental.FieldDefaults;
import org.noear.solon.annotation.Inject;

import java.util.List;

/**
 * <b>(RouterServiceTestBase)</b>
 *
 * @author Peigen
 * @version 1.0.0
 * @since 2021/7/31
 */
@FieldDefaults(level = AccessLevel.PROTECTED)
public class RouterServiceTestBase extends RouterDomainServiceTestBase {
    @Inject
    ReceiptService              receiptService;
    @Inject
    QueryReceiptChannelService  queryReceiptChannelService;
    @Inject
    WithdrawService             withdrawService;
    @Inject
    MultipleWithdrawService     multipleWithdrawService;
    @Inject
    VirtualAccountService       virtualAccountService;
    @Inject
    VirtualAccountManageService virtualAccountManageService;
    @Inject
    GatewayNotifyService        gatewayNotifyService;

    protected List<Order> genOrder(String shopName, Currency originalCurrency, Currency currency, int i) {
        String orderNo = IdUtil.id();
        return Lists.newArrayList(Order.builder()
                .orderId(IdUtil.nextId(orderNo, i))
                .orderNo(IdUtil.nextId(orderNo, i))
                .originTotalAmount(new Money(RandomUtil.randomLong(1, 10), originalCurrency))
                .totalAmount(new Money(RandomUtil.randomLong(6, 60), currency))
                .orderTime(DateUtil.date())
                .customerInfo(OrderCustomer.builder()
                        .name("Peigen_" + i)
                        .address("China_" + i)
                        .mobile("1333333333" + i)
                        .build())
                .logisticsInfo(OrderLogistics.builder()
                        .logisticsCompany("顺丰")
                        .logisticsNo(IdUtil.nextId(orderNo, i))
                        .build())
                .shopInfo(OrderShop.builder()
                        .shopName(shopName + "_" + i)
                        .shopUrl("xxx_" + i + "_.com")
                        .build())
                .goodsList(Lists.newArrayList(OrderGoods.builder()
                        .name("小肉干_" + i)
                        .quantity(RandomUtil.randomDouble(1, 10))
                        .price(new Money(RandomUtil.randomLong(1, 10), currency))
                        .build()))
                .build());
    }

}
